package com.main.hotel.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import javax.persistence.*;
import java.util.Date;

@Entity
@Table(name = "order_info")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class OrderInfo {
  @Id

  private String order_id;
  private String remark;
  private String roomType;
  private  String name;
  @NotFound(action= NotFoundAction.IGNORE)
//  @ManyToOne(cascade = { CascadeType.PERSIST, CascadeType.MERGE }, optional = true)
  @ManyToOne(cascade = { CascadeType.PERSIST},targetEntity = Customer.class,fetch = FetchType.LAZY)
  @JoinColumn(name = "customer_id")
  @JsonIgnore
  private Customer customer;
  private String email;
  private Date order_date;
  private Integer order_days;
  private Integer room_id;
  private Integer member;
  private Integer order_status;
  private Date createTime;
  private float order_cost;
  private String phone;
  private Integer foo;
  @Override
  public String toString() {
    return "OrderInfo{" +
      "order_id=" + order_id +
      ", remark='" + remark + '\'' +
      ", roomType='" + roomType + '\'' +
      ", name='" + name + '\'' +
//      ", customer=" + customer +
      ", email='" + email + '\'' +
      ", order_date=" + order_date +
      ", order_days=" + order_days +
      ", room_id=" + room_id +
      ", member=" + member +
      ", order_status=" + order_status +
      ", create_time=" + createTime +
      ", order_cost=" + order_cost +
      ", phone='" + phone + '\'' +
      '}';
  }
}
